package com.javaclimb.music.service.Impl;

import com.javaclimb.music.dao.SongListMapper;
import com.javaclimb.music.domain.SongList;
import com.javaclimb.music.enums.ResponseEnum;
import com.javaclimb.music.service.SongListService;
import com.javaclimb.music.vo.ResponseVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static com.javaclimb.music.enums.ResponseEnum.*;

/**
 * @author 最酷的桃儿wjc
 * * @date 2022/5/21
 */
@Service
public class SongLIstServiceImpl implements SongListService {

    @Autowired
    private SongListMapper songListMapper;

    /**
     * 获取所有歌单信息
     * @return
     */
    @Override
    public List<SongList> getAllLists() {
        return songListMapper.getAllLists();
    }

    /**
     * 添加歌手
     * @param songList
     * @return
     */
    @Override
    public ResponseVo addSongList(SongList songList) {
        int count = songListMapper.insertSongList(songList);
        if (count == 0){
            return ResponseVo.error(ERROR_INSERT);
        }
        return ResponseVo.success(SUCCESS_INSERT);
    }

    @Override
    public ResponseVo updateSongListPic(SongList songList, String storeAvatorPath) {
        int count = songListMapper.updateSongList(songList);
        if (count == 0){
            return ResponseVo.error(ERROR_UPLOAD);
        }
        Map<String,String> map = new HashMap<>();
        map.put("pic",storeAvatorPath);
        return ResponseVo.success(SUCCESS_UPLOAD);
    }
}
